2020年05月05日
CacheControl等のメタデータではなく、ここではユーザー定義メタデータを指す
$options = [
'SourceFile' => $file->getTempName(),
'ContentType' => $file->getType(),
'CacheControl' => 'no-cache',
'Metadata' => [
'Name' => 'hoge.png'
'Width' => $width,
'Height' => $height,
'Type' => $file->getRealType(),
'Filesize' => $file->getSize(),
]
];
$s3Client->putObject($option);
$iterator = $this->s3Client->getPaginator('ListObjects', [
'Bucket' => 'hogehoge',
]);
foreach ($iterator as $page) {
if (empty($page['Contents'])) continue;
foreach ($page['Contents'] as $object) {
$findOptions = [
'Bucket' => $this->config->s3->bucket,
'Key' => $object['Key'],
];
// $metaData = $object['MetaData']; No Exist
$header = $this->s3Client->headObject($findOptions);// Request every time
$metaData = $header['MetaData'];
}
}